package com.doit.demo04;

import com.sun.org.apache.xpath.internal.SourceTree;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
  筛选出姓张 长度为三的名字
 */
public class test {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("张无忌");
        list.add("周芷若");
        list.add("赵敏");
        list.add("张强");
        list.add("张三丰");

        list.stream().filter(s->s.startsWith("张")).filter(s->s.length()==3)
        .forEach(s-> System.out.println(s));
        System.out.println("------------");
        method();
    }
    public static void method(){
        List<String>list = new ArrayList<>();
        Collections.addAll(list,"李白","李信","李清照","李玉松","张无忌","李二");
        System.out.println("------------------");
        list.stream().filter(s->s.startsWith("张")).forEach(s-> System.out.println(s));
        System.out.println("---------------------");
        list.stream().filter(s->s.length()==2).filter(s->s.startsWith("李")).forEach(s-> System.out.println(s));
    }
}
